#include <math.h>
#include "sc.h"

PixelToPixelOp()
rgb2yuv(in stream unsigned char *rgb,
        out stream unsigned char *yuv)
{
  *yuv = *rgb;
}

PixelToPixelOp()
segment(in stream unsigned char *yuv,
        out stream unsigned char *seg)
{
  *seg = *yuv;
}

PixelFilterOp()
rle(in stream unsigned char *seg,
    out stream unsigned char *rle)
{
  if (((*seg)%16)==15)
  {
    *rle = *seg;
    push();
  }
}

PixelFilterOp()
label(in stream unsigned char *rle,
      out stream unsigned char *lbl)
{
  *lbl = *rle;
  push();
}

GlobalOp()
get_ball(in stream unsigned char *lbl)
{
}

GlobalOp()
get_field(in stream unsigned char *lbl)
{
}

GlobalOp()
get_yellow(in stream unsigned char *lbl)
{
}

GlobalOp()
get_blue(in stream unsigned char *lbl)
{
}

GlobalOp()
get_robot(in stream unsigned char *lbl)
{
}

MAINTYPE MAIN(int argc, char **argv)
{
  STREAM rgb, yuv, seg, rle, lbl;

  scInit(argc, argv);

  capture(&rgb);
  rgb2yuv(&rgb, &yuv);
  segment(&yuv, &seg);
  rle(&seg, &rle);
  label(&rle, &lbl);
  _multi(&lbl);

  get_ball(&lbl);
  get_field(&lbl);
  get_yellow(&lbl);
  get_blue(&lbl);
  get_robot(&lbl);

  return scExit();
}
